package tag;

import java.util.Iterator;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import vo.Name;

public class ForTag extends TagSupport{
	private List<Name> time;
	private String vod;
	private Iterator<Name> iterator;
	
	public void setTime(List<Name> time) {
		this.time = time;
	}
	public void setVod(String vod) {
		this.vod = vod;
	}
	@Override
	public int doAfterBody() throws JspException {
		if(iterator.hasNext()){
			pageContext.setAttribute(vod, iterator.next());
			return EVAL_BODY_INCLUDE;
		}else{
			return SKIP_BODY;
		}
	}	
	@Override
	public int doStartTag() throws JspException {
		 iterator = time.iterator();
		 if(iterator.hasNext()){
			 pageContext.setAttribute(vod, iterator.next());
			 return EVAL_BODY_INCLUDE;
		 }else{
			 return SKIP_BODY;
		 }
	}
	
}
